#!/bin/sh

PW_PATH=/server

if [ ! -d $PW_PATH/logs ]; then
mkdir $PW_PATH/logs
fi
cat /dev/null > $PW_PATH/logs/syslog

echo "===============================================================" | tee -a /server/logs/syslog
echo "=             STARTING Forsaken World Server                  =" | tee -a /server/logs/syslog
echo "=             SERVER LOADING WILL TAKE SOME TIME              =" | tee -a /server/logs/syslog
echo "===============================================================" | tee -a /server/logs/syslog
date | tee -a /server/logs/syslog

echo "=== LOGSERVICE ===" | tee -a /server/logs/syslog
cd $PW_PATH/logservice; ./logservice logservice.conf > $PW_PATH/logs/logservice.log 2>> $PW_PATH/logs/syslog &
sleep 2
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== UNIQUENAMED ===" | tee -a /server/logs/syslog
cd $PW_PATH/uniquenamed; ./uniquenamed gamesys.conf > $PW_PATH/logs/uniquenamed.log 2>> $PW_PATH/logs/syslog &
sleep 3
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== AUTH ===" | tee -a /server/logs/syslog
cd $PW_PATH/authd/build/; ./authd >> $PW_PATH/logs/syslog 2>&1 &
sleep 10
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== GAMEDBD ===" | tee -a /server/logs/syslog
cd $PW_PATH/gamedbd; ./gamedbd gamesys.conf > $PW_PATH/logs/gamedbd.log 2>> $PW_PATH/logs/syslog &
sleep 5
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== BACKDBD ===" | tee -a /server/logs/syslog
cd $PW_PATH/backdbd; ./backdbd gamesys.conf > $PW_PATH/logs/backdbd.log 2>> $PW_PATH/logs/syslog &
sleep 5
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== GACD ===" | tee -a /server/logs/syslog
cd $PW_PATH/gacd; ./gacd gamesys.conf > $PW_PATH/logs/gacd.log 2>> $PW_PATH/logs/syslog &
sleep 5
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== GQUERYD ===" | tee -a /server/logs/syslog
cd $PW_PATH/gqueryd; ./gqueryd gamesys.conf > $PW_PATH/logs/gqueryd.log 2>> $PW_PATH/logs/syslog &
sleep 5
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== GDELIVERYD ===" | tee -a /server/logs/syslog
cd $PW_PATH/gdeliveryd; ./gdeliveryd gamesys.conf > $PW_PATH/logs/gdeliveryd.log 2>> $PW_PATH/logs/syslog &
sleep 5
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== GLINKD ===" | tee -a /server/logs/syslog
cd $PW_PATH/glinkd; ./glinkd gamesys.conf 1 > $PW_PATH/logs/glink.log 2>> $PW_PATH/logs/syslog &
cd $PW_PATH/glinkd; ./glinkd gamesys.conf 2 > $PW_PATH/logs/glink2.log 2>> $PW_PATH/logs/syslog &
cd $PW_PATH/glinkd; ./glinkd gamesys.conf 3 > $PW_PATH/logs/glink3.log 2>> $PW_PATH/logs/syslog &
cd $PW_PATH/glinkd; ./glinkd gamesys.conf 4 > $PW_PATH/logs/glink4.log 2>> $PW_PATH/logs/syslog &
sleep 10
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "=== Realm #1 ===" | tee -a /server/logs/syslog
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias2.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias3.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias4.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias5.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias6.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias7.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias8.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias9.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias10.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias11.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias12.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias13.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias14.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias15.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias20.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias_ins1.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias_ins2.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias_ins3.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias_solo1.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias_solo2.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias_solo3.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
cd $PW_PATH/gamed; ./gs gs.conf gmserver.conf gsalias_kbattle.conf > $PW_PATH/logs/game1.log 2>> $PW_PATH/logs/syslog &
sleep 2
echo "=== DONE! ===" | tee -a /server/logs/syslog
echo "" | tee -a /server/logs/syslog
echo "===============================================================" | tee -a /server/logs/syslog
echo "=                      ALL REALMS LOADED!                     =" | tee -a /server/logs/syslog
echo "=                 SERVERS ARE UP AND RUNNING!                 =" | tee -a /server/logs/syslog
echo "===============================================================" | tee -a /server/logs/syslog



